(function (lib, config) {
    var loadFunc = function () {
        var textAry = config.words.split('|'), bgcolorAry = config.bgcolor.split('|'), textcolorAry = config.textcolor.split('|'), imglinkAry = config.imglink.split('|'), weblinkAry = config.weblink.split('|'), identiAry = config.identifier.split('|');
        textAry[0] = textAry[0] || '您好，点击';
        textAry[1] = textAry[1] || '，专家将根据您关心的';
        textAry[2] = textAry[2] || '问题，快速为您提供<span style="color:#f00;">解决方案</span>，相信一定会帮助到您。';
        bgcolorAry[0] = bgcolorAry[0] || '#f00';
        bgcolorAry[1] = bgcolorAry[1] || '#ff6005';
        textcolorAry[0] = textcolorAry[0] || '#fff';
        textcolorAry[1] = textcolorAry[1] || '#fff';
        textcolorAry[2] = textcolorAry[2] || '#fff';
        imglinkAry[0] = imglinkAry[0] || 'http://nkm.cz120.net/swt/swt20180523/img/btnzx.png';
        imglinkAry[1] = imglinkAry[1] || 'http://nkm.cz120.net/swt/swt20180523/img/btnClose.png';
        identiAry[0] = identiAry[0] || 'swt_dbcs';
        function GetQueryString($name) {
            var $index = document.referrer.indexOf($name + "="), $e = '';
            if ($index > 1) {
                $e = document.referrer.substring($index + $name.length + 1);
                if (($index = $e.indexOf("&")) > 0) {
                    $e = $e.substring(0, $index);
                }
            }
            return $e;
        }
        // 调用方法
        var $wd = GetQueryString("wd");
        if ($wd && $wd.length > 0) { } else { $wd = GetQueryString("word") }
        if ($wd && $wd.length > 0) {
            $wd = decodeURIComponent($wd);
            str1 = '' + textAry[0] + '<a href="javascript:void(0);" onclick=openZoosUrl("chatwin","&e=' + identiAry[0] + '") >立即回复</a>' + textAry[1] + '<span style="color:#f00;">【“' + $wd + '”】</span>' + textAry[2] + '';
        } else {
            str1 = '' + textAry[0] + '<a href="javascript:void(0);" onclick=openZoosUrl("chatwin","&e=' + identiAry[0] + '") >立即回复</a>' + textAry[1] + '<span style="color:#f00;">男科</span>' + textAry[2] + '';
        }
        var floatBottomDiv = [
            '<style>.leftPic{display:table;width:60px;height:60px;position:absolute;z-index:9999;margin-left:0px;transition: all 1s ease;opacity:0;}'
            + '.leftText{transition: all 1s ease;margin-left:0px;}'
            + '#bttc_left{float: left;width: 60px;min-height:60px;position: absolute;z-index: 2147483647;}'
            + '#bottomTanChuang a{text-decoration: none;}'
            + '.leftText{line-height:18px;letter-spacing:2px;text-align:center;font-size:14px;color:' + textcolorAry[0] + ';box-shadow:0px 2px 5px #999; font-weight:500;opacity:1;display:table;width:60px;min-height:60px;background-color:' + bgcolorAry[0] + ';border-radius:100%;animation: all 3s ease;}'
            + '.leftText span{ height:10px;display:block;}'
            + '#bottomTanChuang{min-height: 60px;position: fixed;bottom:120px;left: 1%;top: 60%;transition:width 1s ease;z-index:50;}'
            + '@media screen and (max-width: 900px) and (min-width: 320px){'
                + '#bottomTanChuang{'+lib.util.getPosStyle(config)+'}#bttcclose{margin-left:-10px}}'/*bottom:40%;*/
                + '#bttc_right{margin-left: 40px;width: 0px;min-height: 58px;background-color: rgba(0,0,0,0.75);position: absolute;z-index: 100;transition: all 1s ease;border-top-right-radius:6px;border-bottom-right-radius: 6px;box-shadow: 0px 2px 5px #999;}'
                + '#bttcclose{width: 0px;height: 26px;background: url(' + imglinkAry[1] + ') no-repeat center;background-size: 100%;position: relative;top:-8px;left: 0px;transition: all 1s ease;}'
                + '.bttccontent{text-align: left;display:none;}.bttccontent p{float: right;width:89%;color: ' + textcolorAry[1] + ';font-size: 13px;line-height: 22px;margin-top: -18px;margin-right:5%;}'
                + '.bttccontent a{text-align: center;line-height: 20px;height: 22px;border-radius: 4px;width: 75px;background-color: ' + bgcolorAry[1] + ';color: ' + textcolorAry[2] + ';font-size: 14px;margin-left: 10px;	display: inline-block;}'
                + '</style>',
            '<div id="bottomTanChuang">',
                '<div id="bttc_left">',
                    '<a class="leftPic" href="javascript:void(0);" onclick=openZoosUrl("chatwin","&e=' + identiAry[0] + '") ><img src="' + imglinkAry[0] + '" width="100%"/></a>',
                    '<a class="leftText"  href="javascript:void(0);" onclick=openZoosUrl("chatwin","&e=' + identiAry[0] + '")><span></span>点击<br>问医生</a>',
                '</div>',
                '<div id="bttc_right">',
                    '<div id="bttcclose" onclick="hideBottomTanChuang();"></div>',
                    '<div class="bttccontent">',
                        '<p class="bttcContText">' + str1 + '</p>',
                    '</div>',
                '</div>',
            '</div>'
        ];

        var floatBottomDivInsert = document.createElement('div');
        floatBottomDivInsert.innerHTML = floatBottomDiv.join('');
        document.body.appendChild(floatBottomDivInsert);

        var liCount = 1;
        var showLi = 1;
        var showStatusBttc = true;
        var bottomTanChuang = document.getElementById("bottomTanChuang");
        var bttcRight = document.getElementById("bttc_right");
        var bttcLeft = document.getElementById("bttc_left");
        var leftText = document.getElementsByClassName("leftText")[0];
        var leftPic = document.getElementsByClassName("leftPic")[0];
        var bttcClose = document.getElementById("bttcclose");
        var bttcContent = document.getElementsByClassName("bttccontent")[0];
        var bttcContText = document.getElementsByClassName("bttcContText")[0];

        showBottomTanChuang = function () {
            bottomTanChuang.style.width = "95%";
            bttcLeft.style.backgroundSize = '100%';
            bttcRight.style.width = "90%";
            bttcClose.style.left = "95%";
            bttcClose.style.width = "25px";
            leftText.style.opacity = "0";
            bttcContent.style.display = "block";
            leftText.style.marginLeft = "60px";
            leftPic.style.marginLeft = "0px";
            leftPic.style.opacity = "1";
            showStatusBttc = true;
        }

        hideBottomTanChuang = function () {
            bottomTanChuang.style.width = "60px";
            bttcRight.style.width = "0px";
            bttcClose.style.left = "0";
            leftText.style.marginLeft = "0px";
            bttcClose.style.width = "0";
            leftText.style.opacity = "1";
            leftPic.style.opacity = "0";
            leftPic.style.marginLeft = "-60px";
            bttcContent.style.display = "none";
            showStatusBttc = false;
            setTimeout(showBottomTanChuang, config.relapsetime * 1000);
        }
        setTimeout(showBottomTanChuang, config.firsttime * 1000);
    };
    lib.load(loadFunc);
})('{{lib}}', '{{config}}');